import {
  ProCard,
  ProFormGroup,
  ProFormInstance,
} from '@ant-design/pro-components';
import {
  ProForm,
  ModalForm,
  ProFormDigit,
  ProFormSelect,
  ProFormText,
  ProFormDatePicker,
  ProFormTextArea,
  ProTable,
  ProFormDependency,
} from '@ant-design/pro-components';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { history, useRequest } from 'umi';
import {
  message,
  Button,
  Card,
  Breadcrumb,
  Collapse,
  Upload,
  Descriptions,
  Space,
  Modal,
  Table,
} from 'antd';
import React, { useEffect, useRef, useState } from 'react';
import type { UploadProps } from 'antd';
import {
  PlusOutlined,
  UploadOutlined,
  FileSearchOutlined,
  InboxOutlined,
} from '@ant-design/icons';
import {
  getLabelAdapter,
  isPassAdapter,
  TitleAdapter,
} from '../../commons/Adapter';
import TbaleExplainMap from '@/components/TipsMap';

const { Panel } = Collapse;
const { Dragger } = Upload;

const waitTime = (time: number = 100) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};

export default () => {
  const formRef = useRef<ProFormInstance>();
  const addPersonFrom = useRef<ProFormInstance>();
  const [paperId, setPaperId] = useState('');
  const [filedDisable, setFiledDisable] = useState({
    username: true,
    technicalGrade: true,
    technicalName: true,
    type: true,
  });
  const [proTableData, setProTableData] = useState([]);
  const [updateStatus, setUpdateStatus] = useState(false);
  const [newpath, setNewPath] = useState();

  const [modalDataSource, setModalDataSource] = useState([]); //modal的数据源
  const [selectKeys, setSelectKeys] = useState([]); //modal checkbox默认选中
  const [saveType, setSaveType] = useState(''); //modal 点击确认 调用新增、更新还是暂存接口

  const props: UploadProps = {
    name: 'file',
    action: 'http://10.1.40.84:9993/common/uploadFile',
    headers: {
      Authorization: localStorage.getItem('token') || '',
    },
    maxCount: 1,
    accept: '.docx,.doc,.pdf,.xls',
    onChange(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        formRef.current?.setFieldsValue({
          annexPath: info?.file?.response.data,
        });
        setNewPath(info?.file?.response.data);
        message.success(`${info.file.name} 上传成功！`);
      } else if (info.file.status === 'error') {
        message.error(`${info.file.name} 上传失败！`);
      }
    },
  };

  //根据ID查询论文详情
  const findPaperDetailById = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/paper/findPaperDetailById',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        setProTableData(result.userCommonRelations);
      },
      manual: true,
    },
  );
  //更新论文
  const updatePaper = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/paper/updatePaper',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        console.log(result);
        if (result.code === 200) {
          history.push('/LabAchievements/ScientificResearch/Paper');
        } else {
          message.error(result.msg);
        }
      },
      manual: true,
      formatResult: (res) => res,
    },
  );
  //新增论文
  const addPaper = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/paper/addPaper',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        if (result.code === 200) {
          history.push('/LabAchievements/ScientificResearch/Paper');
        } else {
          message.error(result.msg);
        }
      },
      onError: (e, params) => {
        console.log(e);
        console.log(params);
      },
      formatResult: (res) => res,
      manual: true,
    },
  );
  //查找所有标签
  const getAllLabel = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/getAllLabel',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        console.log(result);
        // history.push('/LabAchievements/ScientificResearch/Paper');
      },
      onError: (e, params) => {
        console.log(e);
        console.log(params);
      },
      // formatResult: res => res
      // manual: true,
    },
  );
  //添加标签
  const addLabelDetail = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/addLabelDetail',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        console.log(result);
        getAllLabel.run();
        message.success('添加成功');
      },
      onError: (e, params) => {
        console.log(e);
        console.log(params);
      },
      // formatResult: res => res
      manual: true,
    },
  );
  //根据名字查找人详细信息
  const findOneUserInfoDetailByName = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/user/findOneUserInfoDetailByName',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );
  //根据职称等级选择职称名称
  const getLike = useRequest(
    (data = { field: 'technicalName', level: '正高级' }) => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
  );
  //获取所有方向/direction/findAllDirection
  const findAllDirection = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/direction/findAllDirection',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        console.log(result);
        // setProTableData(result.userCommonRelations);
      },
      formatResult: (res) => {
        let datatemp: any = [];
        res.data.map((item: any) => {
          let dataObj = {
            key: item.directionName,
            value: item.directionName,
          };
          datatemp.push(dataObj);
        });
        return datatemp;
      },
      // manual: true,
    },
  );
  //
  const addOrUpdatePaperTemp = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/paper/addOrUpdatePaperTemp',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        history.push('/LabAchievements/ScientificResearch/Paper');
        console.log(result);
      },
      manual: true,
    },
  );
  //审核
  const updateStatusIpi = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/common/updateStatus',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );

  //根据userList获取人员列表/user/getUserList
  const getUserList = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/user/getUserList',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
      onSuccess: (result) => {
        console.log(result);
        let resultTemp: any = [];
        result.map((item: any) => {
          resultTemp.push(item.webId);
        });
        console.log(resultTemp);
        setSelectKeys(resultTemp);
      },
    },
  );

  useEffect(() => {
    const paperIdTemp = history.location.pathname.replace(
      '/LabAchievements/ScientificResearch/Paper/EditPaper/',
      '',
    );
    setPaperId(paperIdTemp);
    if (paperIdTemp !== 'new') {
      findPaperDetailById.run({ id: paperIdTemp }).then((e) => {
        //根据审核状态改变 来判断基本信息是否可修改
        // if (e?.isPass == '2') {
        //   setUpdateStatus(true);
        // }
        formRef.current?.setFieldsValue(e);
        setNewPath(e?.annexPath);
      });
    }
  }, []);

  // useEffect(()=>{
  //   getUserList?.data
  // },[])

  const [isModalVisible, setIsModalVisible] = useState(false);
  // const modalForm = useRef<ProFormInstance>();

  const showModal = (value: any) => {
    console.log(value);
    setModalDataSource(value);
    setIsModalVisible(true);
  };

  const handleOk = () => {
    let paramTemp: any = [];
    selectKeys.map((element: any) => {
      paramTemp.push(
        getUserList?.data.filter((item: any) => item.webId === element)[0],
      );
    });
    if (saveType === '暂存') {
      let formRefData: any = formRef.current?.getFieldsValue();
      addOrUpdatePaperTemp.run({
        ...formRefData,
        userCommonRelations: paramTemp,
        id: paperId === 'new' ? null : paperId,
      });
    }
    if (saveType === '新增') {
      let formRefData: any = formRef.current?.getFieldsValue();
      addPaper.run({
        ...formRefData,
        userCommonRelations: paramTemp,
      });
    }
    if (saveType === '更新') {
      let formRefData: any = formRef.current?.getFieldsValue();

      updatePaper
        .run({
          ...formRefData,
          id: paperId,
          userCommonRelations: paramTemp,
        })
        .then(() => {
          if (localStorage.getItem('isEdit') === '审核') {
            updateStatusIpi
              .run({
                tableName: 'PAPER',
                ids: [paperId],
                status: 2, //审核通过
                tab: '子方向视角',
              })
              .then(() => {
                history.goBack();
                message.success('操作成功');
              });
          }
        });
    }
  };

  const handleCancel = () => {
    setIsModalVisible(false);
  };

  return (
    <PageContainer
      header={{
        title: findPaperDetailById?.data?.message ? (
          <div style={{ fontSize: 18, textAlign: 'center', color: 'red' }}>
            拒绝原因：{findPaperDetailById?.data?.message}
          </div>
        ) : null,
        breadcrumb: (
          <Breadcrumb>
            <Breadcrumb.Item>科学研究</Breadcrumb.Item>
            <Breadcrumb.Item>论文</Breadcrumb.Item>
            <Breadcrumb.Item>
              {TitleAdapter(paperId, localStorage.getItem('isEdit'), '论文')}
            </Breadcrumb.Item>
          </Breadcrumb>
        ),
      }}
      extra={
        <div>
          {localStorage.getItem('isEdit') === '审核' ? (
            <Space>
              <ModalForm
                title="返回成员修改"
                trigger={<Button key="2">返回成员修改</Button>}
                autoFocusFirstInput
                modalProps={{
                  onCancel: () => console.log('run'),
                  destroyOnClose: true,
                }}
                submitTimeout={2000}
                onFinish={async (values) => {
                  console.log(values);
                  updateStatusIpi
                    .run({
                      tableName: 'PAPER',
                      ids: [paperId],
                      status: 3, //拒绝
                      message: values.message,
                      tab: '子方向视角',
                    })
                    .then(() => {
                      // findPaperDetailById.run({ id: paperId }).then((e) => {
                      //   formRef.current?.setFieldsValue(e);
                      //   setNewPath(e?.annexPath);
                      // });
                      history.goBack();
                      message.success('操作成功');
                    });
                  return true;
                }}
                grid={true}
                initialValues={{ message: findPaperDetailById?.data?.message }}
              >
                <ProForm.Group>
                  <ProFormText
                    name="message"
                    label="拒绝原因"
                    placeholder="请输入拒绝原因"
                    colProps={{ span: 24 }}
                    rules={[{ required: true, message: '请输入拒绝原因' }]}
                  />
                </ProForm.Group>
              </ModalForm>

              <Button
                key="1"
                type="primary"
                onClick={() => {
                  let formRefData: any = formRef.current?.getFieldsValue();
                  if (!formRefData?.annexPath) {
                    message.warning('请上传材料！');
                  } else {
                    if (paperId === 'new') {
                      setSaveType('新增');
                    } else {
                      setSaveType('更新');
                    }
                    getUserList
                      .run({ userList: formRefData.authors })
                      .then((e) => {
                        showModal(e);
                      });
                  }
                }}
              >
                提交管理员审核
              </Button>
            </Space>
          ) : null}
        </div>
      }
      content={
        <>
          {/* {
            findPaperDetailById?.data?.message ? (
              <div style={{ fontSize: 14, textAlign: 'center', color: 'red' }}>
                拒绝原因：{findPaperDetailById?.data?.message}
              </div>
            ) : null
          } */}
          {localStorage.getItem('isEdit') === '查看' ? (
            <Descriptions layout="horizontal" bordered>
              {localStorage.getItem('identity') === '管理员' &&
              getAllLabel?.data &&
              findPaperDetailById?.data?.labels ? (
                <>
                  <Descriptions.Item
                    label="序号"
                    span={3}
                    labelStyle={{ width: 120 }}
                  >
                    {findPaperDetailById?.data?.seq
                      ? findPaperDetailById?.data?.seq
                      : null}
                  </Descriptions.Item>
                  <Descriptions.Item label="年度" span={3}>
                    {findPaperDetailById?.data?.year
                      ? findPaperDetailById?.data?.year
                      : null}
                  </Descriptions.Item>
                  <Descriptions.Item label="论文标签" span={3}>
                    {getLabelAdapter(
                      getAllLabel?.data,
                      findPaperDetailById?.data.labels,
                    )}
                  </Descriptions.Item>
                </>
              ) : null}

              <Descriptions.Item
                label="论文名称"
                span={3}
                labelStyle={{ width: 200 }}
              >
                {findPaperDetailById?.data?.paperTitle
                  ? findPaperDetailById?.data?.paperTitle
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="所有作者" span={3}>
                {findPaperDetailById?.data?.authors
                  ? findPaperDetailById?.data?.authors
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="期刊类别" span={1}>
                {findPaperDetailById?.data?.periodicalType
                  ? findPaperDetailById?.data?.periodicalType
                  : null}
              </Descriptions.Item>
              <Descriptions.Item
                label="期刊名称"
                span={2}
                labelStyle={{ width: 150 }}
              >
                {findPaperDetailById?.data?.periodicalName
                  ? findPaperDetailById?.data.periodicalName
                  : null}
              </Descriptions.Item>

              <Descriptions.Item
                label="年卷期页"
                span={1}
                contentStyle={{ width: 300 }}
              >
                {findPaperDetailById?.data?.issueNum
                  ? findPaperDetailById?.data.issueNum
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="完成情况" span={1}>
                {findPaperDetailById?.data?.completeState
                  ? findPaperDetailById?.data?.completeState
                  : null}
              </Descriptions.Item>

              <Descriptions.Item
                label="收录情况"
                span={1}
                labelStyle={{ width: 200 }}
              >
                {findPaperDetailById?.data?.collectType
                  ? findPaperDetailById?.data?.collectType
                  : null}
              </Descriptions.Item>
              <Descriptions.Item
                label="刊物类型（SCI按中科院大类分区）"
                span={1}
                labelStyle={{ width: 200 }}
              >
                {findPaperDetailById?.data?.periodicalDetailType
                  ? findPaperDetailById?.data?.periodicalDetailType
                  : null}
              </Descriptions.Item>

              <Descriptions.Item label="是否top" span={1}>
                {findPaperDetailById?.data?.isTop
                  ? findPaperDetailById?.data?.isTop === '是'
                    ? '是'
                    : '否'
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="是否高被引" span={1}>
                {findPaperDetailById?.data?.isHigh
                  ? findPaperDetailById?.data?.isHigh === '是'
                    ? '是'
                    : '否'
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="国重在论文发表单位内排名" span={1}>
                {findPaperDetailById?.data?.gzPaperRank
                  ? findPaperDetailById?.data?.gzPaperRank
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="其他被收录的数据库" span={1}>
                {findPaperDetailById?.data?.otherDB
                  ? findPaperDetailById?.data?.otherDB
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="影响因子" span={1}>
                {findPaperDetailById?.data?.influenceFactor
                  ? findPaperDetailById?.data?.influenceFactor
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="发表年份" span={1}>
                {findPaperDetailById?.data?.publishTime
                  ? findPaperDetailById?.data?.publishTime
                  : null}
              </Descriptions.Item>
              {/* <Descriptions.Item label="页面范围/文章号" span={2}>
              {findPaperDetailById?.data?.pageRange
                ? findPaperDetailById?.data?.pageRange
                : null}
            </Descriptions.Item> */}
              <Descriptions.Item label="第一作者" span={1}>
                {findPaperDetailById?.data?.firstAuthor
                  ? findPaperDetailById?.data?.firstAuthor
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="第一单位" span={2}>
                {findPaperDetailById?.data?.StringfirstCompany
                  ? findPaperDetailById?.data?.StringfirstCompany
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="通讯作者" span={1}>
                {findPaperDetailById?.data?.crpdAuthor
                  ? findPaperDetailById?.data?.crpdAuthor
                  : null}
              </Descriptions.Item>
              <Descriptions.Item label="通讯单位" span={2}>
                {findPaperDetailById?.data?.crpdCompany
                  ? findPaperDetailById?.data?.crpdCompany
                  : null}
              </Descriptions.Item>
              {localStorage.getItem('identity') === '管理员' ? (
                <Descriptions.Item label="研究方向" span={3}>
                  {findPaperDetailById?.data?.researchDire
                    ? findPaperDetailById?.data?.researchDire
                    : null}
                </Descriptions.Item>
              ) : null}
              {/* <Descriptions.Item label="摘要" span={3}>
              {findPaperDetailById?.data?.paperAbstract
                ? findPaperDetailById?.data?.paperAbstract
                : null}
            </Descriptions.Item> */}
            </Descriptions>
          ) : (
            <div>
              {/* <Card> */}
              <ProForm
                onFinish={async (values) => {
                  // await waitTime(2000);
                  // console.log("????");
                  if (!values?.annexPath) {
                    message.warning('请上传材料！');
                  } else {
                    if (paperId === 'new') {
                      setSaveType('新增');
                    } else {
                      setSaveType('更新');
                    }
                    getUserList.run({ userList: values.authors }).then((e) => {
                      showModal(e);
                    });
                  }
                }}
                formRef={formRef}
                formKey="base-form-use-demo"
                autoFocusFirstInput
                submitter={{
                  render: (props, dom) => (
                    <FooterToolbar>
                      {localStorage.getItem('isEdit') === '审核' ? null : (
                        <>
                          {paperId === 'new' ||
                          findPaperDetailById?.data?.isPass + '' === '-1' ? (
                            <Button
                              onClick={() => {
                                setSaveType('暂存');
                                let values = props.form?.getFieldsValue();
                                if (values.authors) {
                                  getUserList
                                    .run({ userList: values.authors })
                                    .then((e) => {
                                      showModal(e);
                                    })
                                    .catch((e) =>
                                      message.error('作者填写有误'),
                                    );
                                } else {
                                  addOrUpdatePaperTemp.run({
                                    ...values,
                                    userCommonRelations: proTableData,
                                    id: paperId === 'new' ? null : paperId,
                                  });
                                }
                              }}
                            >
                              暂存
                            </Button>
                          ) : null}
                          <Button
                            type="primary"
                            onClick={() => {
                              // console.log("?");
                              formRef.current?.submit();
                            }}
                          >
                            提交
                          </Button>
                          {/* {dom} */}
                        </>
                      )}
                    </FooterToolbar>
                  ),
                }}
                grid={true}
                rowProps={{
                  gutter: 16,
                }}
              >
                <ProForm.Group title={'基本信息'}>
                  <ProFormText
                    disabled
                    name="seq"
                    label="序号"
                    colProps={{ span: 6 }}
                    hidden={true}
                  />
                  <ProFormText
                    name="paperTitle"
                    label="论文名称"
                    colProps={{
                      span: 6,
                    }}
                    rules={[{ required: true, message: '请输入论文名称' }]}
                  />
                  <ProFormText
                    name="authors"
                    // disabled
                    label="所有作者（作者信息中本人姓名为英文的请改成中文）"
                    placeholder="请输入所有作者"
                    colProps={{
                      span: 6,
                    }}
                    // tooltip="论文作者信息中本人姓名为英文的请改成中文"
                    rules={[{ required: true, message: '请输入所有作者' }]}
                  />
                  <ProFormSelect
                    request={async () => [
                      {
                        value: '独立完成',
                        label: '独立完成',
                      },
                      {
                        value: '第一完成人(非独立完成)',
                        label: '第一完成人(非独立完成)',
                      },
                      {
                        value: '非第一完成人(非独立完成)',
                        label: '非第一完成人(非独立完成)',
                      },
                    ]}
                    colProps={{
                      span: 3,
                    }}
                    name="completeState"
                    label="完成情况"
                    required
                    rules={[
                      {
                        required: localStorage.getItem('identity') === '管理员',
                        message: '请输入完成情况',
                      },
                    ]}
                  />
                  {/* <ProFormText
                  name="issueNum"
                  label="年卷期页"
                  placeholder="请输入年卷期页"
                  colProps={{ span: 4 }}

                  rules={[{ required: true, message: '请输入年卷期页' }]}
                /> */}

                  <ProFormGroup></ProFormGroup>
                  {/* <Collapse
                      style={{ width: '100%', marginBottom: 10 }}
                      bordered={false}
                      defaultActiveKey={['1']}
                    >
                      <Panel header="论文详细内容" key="1"> */}
                  <ProForm.Group title="详细内容">
                    <ProFormDatePicker.Year
                      name="year"
                      label="年度"
                      colProps={{
                        span: 3,
                      }}
                      hidden={localStorage.getItem('identity') !== '管理员'}
                    />
                    <ProFormText
                      name="periodicalName"
                      label="期刊名称"
                      placeholder="请输入期刊名称"
                      colProps={{
                        span: 3,
                      }}
                      rules={[{ required: true, message: '请输入期刊名称' }]}
                    />

                    <ProFormSelect
                      options={[
                        {
                          value: '国外重要刊物',
                          label: '国外重要刊物',
                        },
                        {
                          value: '国内重要刊物',
                          label: '国内重要刊物',
                        },
                      ]}
                      name="periodicalType"
                      label="期刊类别"
                      rules={[{ required: true, message: '请输入期刊类别' }]}
                      colProps={{
                        span: 3,
                      }}
                    />
                    <ProFormSelect
                      options={[
                        {
                          value: 'SCI',
                          label: 'SCI',
                        },
                        {
                          value: 'EI',
                          label: 'EI',
                        },
                      ]}
                      name="collectType"
                      label="收录情况"
                      rules={[{ required: true, message: '请输入收录情况' }]}
                      colProps={{
                        span: 3,
                      }}
                    />

                    <ProFormDependency name={['collectType']}>
                      {({ collectType }) => {
                        let periodicalDetailTypeRequired: boolean = true;
                        if (collectType === 'SCI') {
                          periodicalDetailTypeRequired = false;
                        }
                        return (
                          <ProFormSelect
                            options={[
                              {
                                value: '一区',
                                label: '一区',
                              },
                              {
                                value: '二区',
                                label: '二区',
                              },
                              {
                                value: '三区',
                                label: '三区',
                              },
                              {
                                value: '四区',
                                label: '四区',
                              },
                            ]}
                            name="periodicalDetailType"
                            label="SCI分区（按中科院大类）"
                            rules={[
                              {
                                required: !periodicalDetailTypeRequired,
                                message: '请输入刊物类型',
                              },
                            ]}
                            colProps={{
                              span: 3,
                            }}
                            disabled={periodicalDetailTypeRequired}
                          />
                        );
                      }}
                    </ProFormDependency>
                  </ProForm.Group>
                  <ProForm.Group title={'发表年卷期页'}>
                    <ProFormDatePicker.Year
                      name="publishYear"
                      label="年"
                      placeholder="请输入年卷期页中“年”"
                      colProps={{ span: 3 }}
                      // initialValue={"2022"}
                      // fieldProps={{
                      //   format: 'YYYY',
                      // }}
                      rules={[
                        { required: true, message: '请输入年卷期页中“年”' },
                      ]}
                    />
                    <ProFormDigit
                      name="roll"
                      label="卷"
                      placeholder="请输入年卷期页中“卷”"
                      min={1}
                      max={100}
                      colProps={{ span: 3 }}
                      rules={[
                        { required: true, message: '请输入年卷期页中“卷”' },
                      ]}
                    />
                    <ProFormDigit
                      name="period"
                      label="期"
                      placeholder="请输入年卷期页中“期”"
                      colProps={{ span: 3 }}
                      rules={[
                        { required: true, message: '请输入年卷期页中“期”' },
                      ]}
                    />
                    <ProFormText
                      name="page"
                      label="页码范围"
                      placeholder="请输入年卷期页中“页”"
                      colProps={{ span: 3 }}
                      rules={[
                        { required: true, message: '请输入年卷期页中“页”' },
                      ]}
                    />
                    <ProFormDatePicker
                      name="publishTime"
                      fieldProps={{
                        format: 'YYYY-MM',
                      }}
                      label="发表年份"
                      colProps={{
                        span: 3,
                      }}
                      rules={[{ required: true, message: '请输入发表年份' }]}
                    />
                  </ProForm.Group>
                  <ProForm.Group title={'影响力'}>
                    <ProFormText
                      name="otherDB"
                      label="其他被收录的数据库"
                      colProps={{
                        span: 3,
                      }}
                    />

                    <ProFormDigit
                      label="国重在论文发表单位内排名"
                      name="gzPaperRank"
                      min={1}
                      max={10}
                      colProps={{
                        span: 3,
                      }}
                    />
                    <ProFormDigit
                      name="influenceFactor"
                      label="影响因子"
                      colProps={{
                        span: 3,
                      }}
                      max={100}
                      fieldProps={{ precision: 3, step: 0.01 }}
                    />
                    <ProFormSelect
                      options={[
                        {
                          value: '是',
                          label: '是',
                        },
                        {
                          value: '否',
                          label: '否',
                        },
                      ]}
                      name="isHigh"
                      label="是否高被引"
                      colProps={{
                        span: 3,
                      }}
                    />

                    <ProFormSelect
                      options={[
                        {
                          value: '是',
                          label: '是',
                        },
                        {
                          value: '否',
                          label: '否',
                        },
                      ]}
                      name="isTop"
                      label="是否top"
                      colProps={{
                        span: 3,
                      }}
                    />
                    {/* <ProFormText
                        name="pageRange"
                        label="页面范围/文章号"
                        colProps={{
                          span: 4,
                        }}

                      /> */}
                  </ProForm.Group>
                  <ProForm.Group title={'作者信息'}>
                    <ProFormText
                      name="firstAuthor"
                      label="第一作者"
                      colProps={{
                        span: 3,
                      }}
                      rules={[{ required: true, message: '请输入' }]}
                    />
                    <ProFormText
                      name="StringfirstCompany"
                      label="第一单位"
                      colProps={{ span: 3 }}
                      rules={[{ required: true, message: '请输入' }]}
                    />
                    <ProFormText
                      name="crpdAuthor"
                      label="通讯作者"
                      colProps={{
                        span: 3,
                      }}
                      rules={[{ required: true, message: '请输入' }]}
                    />
                    <ProFormText
                      name="crpdCompany"
                      label="通讯单位"
                      colProps={{
                        span: 3,
                      }}
                      rules={[{ required: true, message: '请输入' }]}
                    />
                    <ProFormSelect
                      name="researchDire"
                      label="研究方向"
                      colProps={{
                        span: 12,
                      }}
                      fieldProps={{
                        options: findAllDirection?.data || [],
                      }}
                      hidden={true}
                      disabled
                      required
                    />
                  </ProForm.Group>
                  <ProForm.Group title={'佐证材料'}>
                    <ProFormSelect
                      // width="lg"
                      options={getAllLabel?.data}
                      mode="tags"
                      name="labels"
                      label="论文标签"
                      hidden={localStorage.getItem('identity') !== '管理员'}
                      addonAfter={
                        <ModalForm<{
                          year: string;
                          labelName: string;
                        }>
                          title="新增标签"
                          trigger={<a>新增标签</a>}
                          autoFocusFirstInput
                          modalProps={{
                            onCancel: () => console.log('run'),
                          }}
                          submitTimeout={2000}
                          onFinish={async (values) => {
                            addLabelDetail.run(values);
                            return true;
                          }}
                        >
                          <ProForm.Group>
                            <ProFormDatePicker.Year
                              width="md"
                              name="year"
                              label="标签年份"
                              required
                            />
                            <ProFormText
                              width="md"
                              name="labelName"
                              label="标签名称"
                              required
                            />
                          </ProForm.Group>
                        </ModalForm>
                      }
                      colProps={{
                        span: 12,
                      }}
                    />
                  </ProForm.Group>
                  {/* </Panel>
                    </Collapse> */}
                  {/* <ProFormTextArea
                  name="paperAbstract"
                  label="摘要"
                  fieldProps={{
                    rows: 6,
                  }}

                /> */}
                  <ProFormText
                    name={'annexPath'}
                    label={'材料地址'}
                    placeholder="待审核"
                    hidden
                  />
                  <ModalForm
                    title="上传材料"
                    trigger={
                      <Button icon={<UploadOutlined />} type="link">
                        上传材料（上传正式发表的论文全名，以论文名称命名）
                      </Button>
                    }
                    autoFocusFirstInput
                    submitTimeout={2000}
                    onFinish={async (values) => true}
                  >
                    {/* TbaleExplainMap['STANDARD'] 要修改 */}
                    <ProCard title={TbaleExplainMap['PAPER']}>
                      {/* 有小问题，需要修改成pro的dragger */}
                      <Dragger {...props} maxCount={1}>
                        <p className="ant-upload-drag-icon">
                          <InboxOutlined />
                        </p>
                        <p className="ant-upload-text">
                          单击或拖动文件到此区域进行上传
                        </p>
                        <p className="ant-upload-hint">请上传一个文件</p>
                      </Dragger>
                    </ProCard>
                  </ModalForm>
                  <Button
                    type="link"
                    onClick={() => {
                      newpath
                        ? window.open(newpath)
                        : message.info('请上传材料');
                    }}
                    icon={<FileSearchOutlined />}
                  >
                    查看材料
                  </Button>
                </ProForm.Group>
              </ProForm>
              {/* </Card> */}
            </div>
          )}
        </>
      }
    >
      <Modal
        title="请确认人员！"
        visible={isModalVisible}
        onOk={handleOk}
        onCancel={handleCancel}
        forceRender
      >
        <Table
          size="small"
          pagination={{ hideOnSinglePage: true, pageSize: 10 }}
          rowKey={'webId'}
          rowSelection={{
            onChange: (selectedRowKeys: React.Key[]) => {
              setSelectKeys(selectedRowKeys);
            },
            selectedRowKeys: selectKeys,
          }}
          columns={[
            {
              title: '工号',
              dataIndex: 'username',
              key: 'username',
            },
            {
              title: '姓名',
              dataIndex: 'realName',
              key: 'realName',
            },
            {
              title: '人员类型',
              dataIndex: 'userType',
              key: 'userType',
            },
          ]}
          dataSource={modalDataSource}
        />
      </Modal>
    </PageContainer>
  );
};
